package com.eckey.lab.controller;

import com.eckey.lab.entity.OrderInfo;
import com.alibaba.fastjson.JSON;
import com.eckey.pub.annotation.AllowList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: ChengLiang
 * @CreateTime: 2023-05-22  15:20
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/allow")
public class AllowListController {

    @AllowList(keyWord = "userName", result = "{\n" +
            "    \"data\": \"请使用合法账号访问\",\n" +
            "    \"errorCode\": \"100001\",\n" +
            "    \"message\": \"非法用户\"\n" +
            "}")
    @GetMapping("/test")
    public String getOrderById(@RequestParam("userName") String userName, @RequestParam Long id) {
        log.info("根据userId：{},订单id:{},查询订单信息", userName, id);
        OrderInfo orderInfo = new OrderInfo(001L, 1001L, 10000.0, 5, "水杯");
        return JSON.toJSONString(orderInfo);
    }

    @GetMapping("/test1")
    public String test(Long userId) {
        return "测试";
    }
}
